<template>
  <div class="common-details">
    <customDetailsTopbar title="企业详情" />
    <custom-radio-tag1 class="mx-1 mb-1 w-100" :list="list" check-value="基本信息" @change="tagChange" />
    <div class="d-scroll listInner bg-white mx-1 px-1">
      <component :is="currentComponent" :company-id="companyId" />
    </div>
  </div>
</template>
<script>
import BasicComponent from './components/basic.vue'
import SafetyComponent from './components/safety.vue'
import EnvironmentComponent from './components/environment.vue'
import EnergySourcesComponent from './components/energySources.vue'
import FireFightingComponent from './components/fireFighting.vue'
import customDetailsTopbar from '@/components/globals/custom-details-topbar.vue'

export default {
  components: {
    customDetailsTopbar,
    BasicComponent,
    SafetyComponent,
    EnvironmentComponent,
    EnergySourcesComponent,
    FireFightingComponent
  },
  data() {
    return {
      currentComponent: 'BasicComponent',
      list: [
        {
          label: '基本信息',
          key: '安全生产,环保管理,消防管理,能源管理,碳排放管理',
          value: 'BasicComponent'
        },
        {
          label: '安全信息',
          key: '安全生产',
          value: 'SafetyComponent'
        },
        {
          label: '环保信息',
          key: '环保管理',
          value: 'EnvironmentComponent'
        },
        {
          label: '消防信息',
          key: '消防管理',
          value: 'FireFightingComponent'
        },
        {
          label: '能源信息',
          key: '能源管理',
          value: 'EnergySourcesComponent'
        }
      ],
      companyId: '',
      current: ''
    }
  },
  created() {
    const { current, companyId } = this.$route.query
    this.companyId = companyId || ''
    this.current = current || ''
  },
  mounted() {
    this.list = this.list.filter((v) => {
      return v.key.indexOf(this.current) > -1
    })
  },
  methods: {
    // tag标签页切换
    tagChange(tagArg) {
      const { label } = tagArg.item
      this.list.map((v) => {
        if (v.label === label) {
          this.currentComponent = v.value
        }
      })
    }
  }
}
</script>
